package cn.modoumama.excelUilt.common;

import java.text.SimpleDateFormat;
import java.util.Date;

public class Common {
    //2010之前的EXCEL后缀名
    public static final String OFFICE_EXCEL_2003_POSTFIX = "xls";
    //2010之后的EXCEL后缀名
    public static final String OFFICE_EXCEL_2010_POSTFIX = "xlsx";

    /**
     * 解析时间
     *
     * @param clazz 需要转换成的类型
     * @param date java.util.Date
     * @return 返回传入的值
     */
    public static <T> Object parsDate(Class<T> clazz, Date date) {
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
        if (clazz == java.util.Date.class) {
            return date;
        } else if (clazz == java.sql.Date.class) {
            return new java.sql.Date(date.getTime());
        } else if (clazz == java.sql.Time.class) {
            return new java.sql.Time(date.getTime());
        } else if (clazz == java.sql.Timestamp.class) {
            return new java.sql.Timestamp(date.getTime());
        }
        return sdf.format(date);
    }
    
}
